﻿<#include "include/_meta.html">
<title>我要还车</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 还车管理 <span class="c-gray en">&gt;</span> 还车列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		订单编号：<input type="text" class="input-text" style="width:250px" placeholder="输入订单编号" id="orderid" name="orderid">
		客户手机：<input type="text" class="input-text" style="width:250px" placeholder="输入客户手机" id="mobile" name="mobile">
		<input type="hidden" style="width:250px" id="realettime" name="realettime" value="${(info.realettime)!''}">
		<button type="submit" class="btn btn-success" id="searchOrders" name=""><i class="Hui-iconfont">&#xe665;</i> 搜订单</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"> </span> <span class="r">共有数据：<strong id="pageTotal">54</strong> 条</span> </div>
	<table id="orderListTable" class="table table-border table-bordered table-bg table-hover">
		<thead>
			<tr>
				<th scope="col" colspan="9">订单列表</th>
			</tr>
			<tr class="text-c">
				<th >订单号</th>
				<th >客户手机</th>
				<th >客户姓名</th>
				<th >车辆型号</th>
				<th >车牌号</th>
				<th >车牌颜色</th>
				<th >租车日期</th>
				<th >还车日期</th>
				<th >操作</th>
			</tr>
		</thead>
		<tbody>

		</tbody>
	</table>
</div>

<#include "include/_footer.html">

<script type="text/javascript">

$(function(){

    initTable();
  
});


var initTable = function(){


$('#orderListTable').dataTable( {
    	"processing": false,
      	"serverSide": true,
      	"bSort": false,
      	"bFilter":false,
      	"bLengthChange":false,
      	"iDisplayLength":10,
      	"bRetrieve":true,
      	"ajax": {
            "url": "/carorders",
           	"data":function(d){
		        d.mobile = $('#mobile').val();
				d.orderid = $('#orderid').val();
		        d.realettime=$('#realettime').val();
		    },
            "type": "get"
        },
        "columns": [
            { "data": "orderid" },
            { "data": "mobile" },
            { "data": "name" },
            { "data": "carbrandtype" },
            { "data": "carcode" },
            { "data": "carcolor" },
            { "data": "realbttime" },
			{ "data": "realettime" },
            { "data": "" },
            
      	],
      	"columnDefs": [

	        {
		          "targets": [8],
		          "data": "orderid",
		          "render": function(data, type, full) {
		          		var action_edit = "<a title=\"编辑\" href=\"javascript:;\" onclick=\"admin_edit('订单编辑','/orderlisttwo?orderid="+full.orderid+"&realettime="+full.realettime+"','2','1050','500')\" class=\"ml-5\" style=\"text-decoration:none\">我要还车</a>";
		          		var action_check ="<a title=\"编辑\" href=\"javascript:;\" onclick=\"admin_edittwo('订单确认','/ ordercheck?orderid="+full.orderid+"&realettime="+full.realettime+"','2','1050','500')\" class=\"ml-5\" style=\"text-decoration:none\">审核</a>";
		            	return action_edit+" "+action_check; 
		          }
	        }	        
      	],
      	"fnRowCallback" : function(nRow, aData, iDisplayIndex) { 
      					                   
                        return nRow;  
         },
	    "fnDrawCallback": function(oSettings) {
		      //获取后台方式 直接可以拿到json 之后进行处理
		      var json=jQuery.parseJSON(oSettings.jqXHR.responseText);  
		      $("#pageTotal").html(json.recordsTotal);
	    }

 });
 
}

$("#searchOrders").click(function() {
        $("#orderListTable").dataTable().fnClearTable();
        initTable();
});


/*
	参数解释：
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/
/*管理员-编辑*/
function admin_edit(title,url,id,w,h){ 
	var index = url.indexOf("e=");
	var str = url.substring(index+2);
	if(str != "null"){
		alert("车子已还，等待审核！");
		return false;
	}
	layer_show(title,url,w,h);
}


function admin_edittwo(title,url,id,w,h){ 
	var index = url.indexOf("e=");
	var str = url.substring(index+2);
	var timestamp = Date.parse(new Date());
	timestamp = timestamp / 1000;
	var timestamp2 = Date.parse(new Date(str));
	timestamp2 = timestamp2 / 1000;
	var day = Math.floor((timestamp-timestamp2)/86400); 
	if(str=="null"){
		alert("请先还车！");
		return false;
	}
	if(day<7){
	var time=7-day;
	alert("审核时间未到，不能审核，请您"+time+"天后来结算现金");
	return false;
	}
	layer_show(title,url,w,h);
}
</script>
</body>
</html>